package kr.hkit.powerjava.chapter10;

import java.util.Arrays;
import java.util.Random;

public class LottoGenerater {
	private int[] arr;
	private static final int SIZE = 6;
	private Random rnd;
	
	public LottoGenerater() {
		arr = new int [LottoGenerater.SIZE];
		rnd = new Random();
		//SIZE만 해도되지만 FM은..
	}
	
	public void getLottoNum(){
		int num = -1;
		for(int i  = 0; i< arr.length; i ++){
	/*		arr[i] = rnd.nextInt(45)+1;*/  //함수가 두가지 기능을 하고 있다. getNum()함수를 따로 만들자
			/*arr[i] = getNum();*/				//함수는 한가지 기능만 갖도록 만들자!~~~~(재사용)
			num = getNum();
			if(!isFind(num)){
//중복			num = getNum();
				i--;
			}else{
				arr[i] = num;
			}
		}												
	} 
	
	public int getNum(){
		return rnd.nextInt(45)+1;
	}
	
	public boolean isFind(int searchNum){
		boolean isEquals = false;
		for(int i = 0; i < arr.length; i++){
			if(searchNum == arr[i]){
				isEquals = true;
				break;
			}
		}
		System.out.println(isEquals);
		return isEquals;
	}
		
	@Override
	public String toString() {
		return "LottoGenerater " + Arrays.toString(arr);
	}

	public static void main(String[] args) {
		
/*		int i = rnd.nextInt(45);*/ //rnd. ctrl+space 함수가 두개 나온다.. (int n) 45개범위 안에서 난수발생
		LottoGenerater lo = new LottoGenerater();
		lo.getLottoNum();
		System.out.println(lo);
/*		String result = lo.isFind(30)?"Find":"Not Find";*/
	}
	
}
